package demo;
class Per implements Cloneable{
    public int id;
    public Money money=new Money();

    @Override
    protected Object clone() throws CloneNotSupportedException {
        //return super.clone();
        Per tmp=(Per) super.clone();
        tmp.money=(Money) this.money.clone();
        return tmp;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                '}';
    }
}
class Money implements Cloneable{
    double m=2.5;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test2 {
    public static void main(String[] args) throws CloneNotSupportedException{
        Per per=new Per();
        Per per1=(Per) per.clone();
        per1.money.m=5.0;
        System.out.println(per.money.m);
        System.out.println(per1.money.m);


    }
}
